package com.example.lzwphoto.service.impl;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.lzwphoto.enity.Photo;
import com.example.lzwphoto.mapper.PhotoMapper;
import org.springframework.stereotype.Service;

import java.io.File;

/**
 * @Desc: TODO
 * @Author: LvKun
 * @Date: 2024-02-05
 * @Version: 1.0
 */

@Service
public class PhotoServiceImpl extends ServiceImpl<PhotoMapper, Photo> implements IService<Photo> {

    public void delPhotoByServiceMachinePath (Long id) {
        Photo photo = this.getById(id);

        File file = new File( photo.getPath() );

        if (file.exists() && file.isFile()) {
            file.delete();
        }
    }

}
